<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 时间戳     获取这个 1970 1 1 8.00 到这个时间的毫秒数
        var a = +new Date('1970-1-1 9:00:00');
        // console.log(a);

        // 计算现在到某个时间还剩多久
        var a1 = +new Date();
        var a2 = +new Date('2021-3-29 16:00:00');

        var a3= a2-a1;
        console.log(a3);  //毫秒

        console.log(parseInt(a3/1000 % 60)); //秒

        console.log(parseInt(a3/1000/60 % 60)); // 分钟

        console.log(parseInt(a3/1000/60/60 % 24)); //小时

        // console.log();
    </script>
</body>
</html>